<template>
	<loading-wait v-if="loading" ></loading-wait>
	<view class="uni-global-box">
		<view class="uni-global-title">
			任务消息 / 举报列表
		</view>
		<view class="">
			<view class="class-manage-top">
				<view class=""> 
					<u-button type="primary" size="mini" @click="goUrl('./add?total='+count)" disabled="" >
						<text class="iconfont icon-shuliang-zengjia"></text>
						<text> &nbsp;新 增</text>
					</u-button>
				</view>
				
			</view>
			<u-table class="u-table-senior">
				<u-tr style="margin-right:15px;">
					<u-th class="u-table-th" width="200px">举报图片</u-th>
					<u-th class="u-table-th" >举报类型</u-th>
					<u-th class="u-table-th" >举报内容</u-th>
					<u-th class="u-table-th" >被举报对象</u-th>
					<u-th class="u-table-th" >被举报角色</u-th>
					<u-th class="u-table-th" >举报用户</u-th>
					<u-th class="u-table-th" >处理结果</u-th>
					<u-th class="u-table-th" >举报时间</u-th>
					<u-th width="100px">操作</u-th>
				</u-tr>
				<view class="u-table-senior-body" style="height:65vh">
					<loaders v-if="data==0"></loaders>
					<u-tr v-for="(item,index) in data" :key="index" class="u-table-tr">
						<u-td class="u-table-td" width="200px">
							<u-swiper :list="item.image" height="150" @click="eventImage(item.image)" ></u-swiper>
						</u-td>
						<u-td class="u-table-td">
							{{item.report_type}}
						</u-td>
						<u-td class="u-table-td">
							{{item.content}}
						</u-td>
						<u-td class="u-table-td">
							{{item.report.name}}
						</u-td>
						<u-td class="u-table-td">
							{{item.type =='tech'?"技师":"店铺"}}
						</u-td>
						<u-td class="u-table-td">
							{{item.userinfo.name}}
						</u-td>
						<u-td class="u-table-td">
							<text v-if="!!item.status[item.status.length -1].value">{{
								item.status[item.status.length -1].text
							}}</text>
							<text v-else class="uni-color-error">
								暂未处理
							</text>
						</u-td>
						<u-td class="u-table-td">
							<uni-dateformat :date="item.create_time" ></uni-dateformat>
						</u-td>
						
						<u-td class="u-table-td " width="100px">
							<view class="u-table-td-util">
								<u-button size="mini" @click="goUrl('./detail?uid='+item._id)" type="primary" >
									<text class="iconfont icon-chakan"></text>
									<text>详情</text>
								</u-button>
							</view>

						</u-td>
					</u-tr>
				</view>
				<view class="u-table-senior-pagination">
					<uni-pagination @change="enventPages" :total="count"></uni-pagination>
				</view>
			</u-table>
		</view>


	</view>
	<u-toast ref="uToast" />
</template>

<script>
	const global = uniCloud.importObject("global",{customUI:true});
	export default {
		data() {
			return {
				loading:false,
				data: [],
				where: {},
				// 分页
				limit:10,
				skip:0,
				count:0,
			}
		},
		onLoad() {
			this.getData();
		},
		methods: {
			getData() {
				const field = "_id,userinfo,report,content,image,create_time,report_type,type,status";
				global.getList('report',this.where,"create_time desc",field ,this.skip,this.limit).then(result => {
					const data = result.data ;
					this.count = result.count;
					this.data = data;
					this.loading = false
				})
			},
			// 删除数据
			async removeData(item,index){
			},
			// 分页
			enventPages(val){
				this.loading = true
				this.skip = ( val.current-1) * 10 ;
				this.getData()
			},
			goUrl(url){
				uni.navigateTo({url})
			},
			// 图片放大
			eventImage(image) {
				if(typeof image == 'string'){
					image = [image];
				}
				uni.previewImage({
					urls: image,
				});
			},
		}
	}
</script>

<style  scoped lang="scss" >
	.class-manage-top{
		display: flex;
		padding:5px 20px ;
		justify-content:flex-end;
	}
</style>